﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using YaAppoint.DepartmentDeviceTypes;
using YaAppoint.DeviceTypes;

namespace YaAppoint.Web.Controllers
{
    /// <summary>
    /// 科室设备类型控制器
    /// </summary>
    public class DepartmentDeviceTypeController(IDepartmentDeviceTypeAppService departmentDeviceTypeAppService) : AbpController
    {
        private readonly IDepartmentDeviceTypeAppService _departmentDeviceTypeAppService = departmentDeviceTypeAppService;

        /// <summary>
        ///  获取科室设备类型列表
        /// </summary>
        [HttpGet("/api/depart-device-type/get-dep-device-types")]
        public async Task<IActionResult> GetDepDeviceTypes(Guid id, string? filterName, int page, int pageSize)
        {
            return new JsonResult(await _departmentDeviceTypeAppService.GetDepDeviceTypes(id, filterName, page, pageSize));
        }

        /// <summary>
        ///  获取系统科室类型列表
        /// </summary>
        [HttpGet("/api/depart-device-type/get-system-device-types")]
        public async Task<IActionResult> GetSystemDeviceTypes(Guid depId, string? filterName, int page, int pageSize)
        {
            return new JsonResult(await _departmentDeviceTypeAppService.GetSystemDeviceTypes(depId,filterName, page, pageSize));
        }

        /// <summary>
        /// 向科室添加
        /// </summary>
        [HttpPost("/api/depart-device-type/add-to-department")]
        public async Task<IActionResult> AddDeviceTypeToDepartment([FromBody] List<DeviceTypeDto> dtoList, Guid depId)
        {
            return new JsonResult(await _departmentDeviceTypeAppService.AddDeviceTypeToDepartment(dtoList,depId));
        }

        /// <summary>
        /// 提交新建
        /// </summary>
        [HttpPost("/api/depart-device-type/submit-create")]
        public async Task<IActionResult> SubmitCreate([FromBody]CreateDeviceTypeDto dto,Guid depId)
        {
            return new JsonResult(await _departmentDeviceTypeAppService.SubmitCreate(dto,depId));
        }

        /// <summary>
        /// 移除多个设备类型
        /// </summary>
        [HttpPost("/api/depart-device-type/remove-many")]
        public async Task<IActionResult> RemoveMany([FromBody]List<DeviceTypeDto> dtoList,[FromQuery] Guid depId)
        {
            return new JsonResult(await _departmentDeviceTypeAppService.RemoveMany(dtoList, depId));
        }


        /// <summary>
        /// 移除单个设备类型
        /// </summary>
        [HttpGet("/api/depart-device-type/remove-single")]
        public async Task<IActionResult> RemoveSingle(Guid deviceTypeId, Guid depId)
        {
            return new JsonResult(await _departmentDeviceTypeAppService.RemoveSingle(deviceTypeId,depId));
        }

        [HttpGet("/api/depart-device-type/get-check-in-mode-options")]
        public IActionResult GetCheckInModeOptions()
        {
            return new JsonResult(_departmentDeviceTypeAppService.LoadCheckInModeOptions());
        }
    }
}
